/*
前馈神经网络主程序
演示神经网络的基本使用和训练流程
包含完整的训练和测试示例
*/
#include "NeuralNetwork.h"
#include <vector>
#include <iostream>

int main() {
    // Example: XOR problem
    std::vector<int> topology = {2, 4, 1}; // Input: 2, Hidden: 4, Output: 1
    NeuralNetwork nn(topology);

    // Training data (XOR)
    std::vector<std::vector<double> > inputs = {
        {0, 0},
        {0, 1},
        {1, 0},
        {1, 1}
    };
    std::vector<std::vector<double> > targets = {
        {0},
        {1},
        {1},
        {0}
    };

    // Train the network
    for (int epoch = 0; epoch < 1000; ++epoch) {
        for (size_t i = 0; i < inputs.size(); ++i) {
            nn.feedForward(inputs[i]);
            nn.backPropagate(targets[i]);
        }
    }

    // Test the network
    for (const auto& input : inputs) {
        nn.feedForward(input);
        std::vector<double> output = nn.getOutput();
        std::cout << "Input: [" << input[0] << ", " << input[1] << "] -> Output: " << output[0] << std::endl;
    }

    return 0;
}